IF EXISTS (SELECT *
           FROM INFORMATION_SCHEMA.ROUTINES
           WHERE ROUTINE_NAME='pInProdPaper_Delete'
           AND ROUTINE_SCHEMA='dbo'
           AND ROUTINE_TYPE='PROCEDURE'
          )
          DROP PROCEDURE dbo.pInProdPaper_Delete
GO

CREATE PROC dbo.pInProdPaper_Delete
	@id  AS INT
AS

	IF (NOT EXISTS(SELECT 1 FROM dbo.InProdDetail WHERE InProdPaperId = @id))
	BEGIN
		 DELETE FROM  dbo.InProdPaper
		 WHERE Id = @id
	END